<%@ Page Title="" Language="C#" MasterPageFile="~/GUI/MasterPage.master" AutoEventWireup="true" CodeFile="Categories.aspx.cs" Inherits="Home_Categories" %>



<%@ Register Src="../Controls/ListCategory.ascx" TagName="ListCategory" TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $(".CheckBox input[type='checkbox']").click(function () {
                if (this.checked == true) {
                    $(this).attr("value", "checked");
                } else {
                    $(this).attr("value", "");
                }
            });


        });
    </script>
    <script type="text/javascript">
        function CheckNull() {
            var Name = document.getElementById('txtName');
            var ErrorPlatformName = document.getElementById('ErrorCategoryName');
            if (Name.value == "") {
                ErrorPlatformName.innerHTML = '<%=Language["ErrorNull"] %>';
                return false;
            } else if(!validText(Name.value)) {
                ErrorPlatformName.innerHTML = '<%=Language["ErrNotacceptScharacters"] %>';
                return false;
            } else {
                return true;
            }
        }
        //check special character
        function validText(value) {
            var chaos = new Array("'", "~", "@", "#", "$", "%", "^", "&", "*", ";", "/", "\\", "|", "<", ">");
            var sum = chaos.length;
            for (var i in chaos) { if (!Array.prototype[i]) { sum += value.lastIndexOf(chaos[i]) } }
            if (sum) {
                return false;
            }
            return true;
        }
    </script>
    <div class="First">
        <div class="IconTitle"><img src="../Images/icon_title.png"/></div>
        <div class="Title"><%= Language[title] %></div>
    </div>
    <div class="Second">
        <div class="BoxAddCategories">
            <div class="CategoriesItem1">
                <div class="ClassLabel"><%= Language["CategoryName"] %></div>
                <input type="text" id="txtName" value="<%=currentCategory.Name %>" name="txtName" />
                <div class="ClassError1" id="ErrorCategoryName"></div>
            </div>
            <div class="CategoriesItem2">
                <div class="ClassLabel"><%=Language["Platform"]%>:</div>
                <div class="CheckBox">
                    <%if (platforms.Count > 0)
                      {
                          for (int i = 0; i < platforms.Count; i = i + 1)
                          {
                    %>
                    <div class="ItemCheckbox">
                        <input type="checkbox" id="<%=platforms[i].ID%>" name="platform_<%=platforms[i].ID%>" <%=isCheckPlatform(platforms[i].ID) %> value="<%=isCheckPlatform(platforms[i].ID) %>" /><label for="Ios"><%=platforms[i].Name %></label>
                    </div>
                    <%}

                          }

                      else
                      { %>
                    <p>
                        <%=Language["noresult"]%>
                    </p>

                    <%} %>
                    <asp:HiddenField runat="server" Value="" ID="platfromId" />
                </div>
            </div>
            <div class="CategoriesItem3">
                <asp:Button Text="Add new category" CssClass="BtnAddNewCategory" ID="btn_create" runat="server" BorderStyle="None" Font-Size="Medium" Height="36px" Width="346px" OnClientClick="return CheckNull();" OnClick="btn_create_Click" />
            </div>
        </div>
         <uc1:ListCategory ID="ListCategory1" runat="server" />
    </div>
</asp:Content>

